package com.fddh.springboot.service.impl;

import com.fddh.springboot.dto.OptionsDto;
import com.fddh.springboot.dto.QuestionDto;
import com.fddh.springboot.entity.Question;
import com.fddh.springboot.mapper.QuestionMapper;
import com.fddh.springboot.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("QuestionServiceImpl")    //注释为服务，指定bean名称为QuestionServiceImpl
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private  QuestionMapper questionMapper;

    @Override
    public int addQuestion(QuestionDto questionDto) {
        //插入条数
        int insertNum = 0;
        insertNum = questionMapper.addQuestion( questionDto );//插入操作
        return insertNum;
    }

    @Override
    public List<Question> getQuestionList() {

        List<Question> list;
        list = questionMapper.getQuestionList();//得到用户列表
        return list;
    }

    @Override
    public int addOptions(OptionsDto optionDto) {
        //插入条数
        int insertNum = 0;
        insertNum = questionMapper.addOptions(optionDto);
        return insertNum;
    }

}
